package org.six11.olive3.server;

import javax.naming.NamingException;

import org.six11.olive3.net.MessageNames;
import org.six11.olive3.server.OliveRuntimeData.Route;
import org.six11.olive3.util.MultiState;

/**
 * This InkBroker subclass establishes message handlers and routing for chat messages and
 * collaborative ink data.
 * 
 * @author Gabe Johnson <johnsogg@cmu.edu>
 */
public class SharedCanvasInkBroker extends InkBroker {

  /**
   * 
   */
  public SharedCanvasInkBroker() throws NamingException {
    super();

    // set routing for pen input to go to everybody except the originating user
    data.setRouting(MessageNames.MSG_PEN, Route.ALL_NO_ECHO);

    // Ensure pen messages are added to the global message queue
    handler.registerAsynchronousHandler(MessageNames.MSG_PEN, recordMessageHandler);

    // register various other message handlers.
//    handler.registerSynchronousHandler(MessageNames.MSG_LOGIN, new InitMessageHandler());
    handler.registerSynchronousHandler(MessageNames.MSG_REQUEST_DOWNLOAD,
        new DownloadMessageHandler(data, new MultiState()));
  }

}
